#include "gui_script_functions.h"
#include "../ServiceLocator.h"
#include "../StateStack.h"
#include "../State.h"

namespace gui
{

Button *CreateButton(Container* parent, const std::string &name, int x, int y, int width, int height, const std::string& caption, Resource<sdl::Font> *fnt)
{
    Button *newButton = new Button( name, width, height, caption, fnt );
    
    parent->AddComponent( newButton, x, y );
    
    StateStack *stateStack = ServiceLocator< StateStack >::GetService( );
    
    newButton->AddActionListener( stateStack->Top( ) );  
    
    return newButton;
}


Picture *CreatePicture(Container* parent, const std::string &name, int x, int y, const std::string &path)
{
    Picture *pic = new Picture( name, path );
    
    parent->AddComponent( pic, x, y );
    
    return pic;
}


Label *CreateLabel(Container* parent, const std::string &name, const std::string& txt, int x, int y, int width, int height, Resource<sdl::Font> *fnt)
{
    Label *lbl = new Label( name, width, height, txt, sdl::Colors::BLACK, fnt );
    
    parent->AddComponent( lbl, x, y );
    
    return lbl;
}

}